<?php
require_once("RemoveModel.php");
require_once("DBConfig.php");
require_once("Database.php");
require_once("LoginHandler.php");

class RemoveController{
	
		private $m_db = NULL;
	
		public function __construct(Database $db){
			$this->m_db = $db;
		}
		
		public function RemoveControl(){
		$removemodel = new RemoveModel($this->m_db);
		$removeview = new RemoveView();
		$DBConfig = new DBConfig();
		$loginhandler = new LoginHandler($this->m_db);
			/*
			if($removemodel->test($db)){
				return TRUE;
			}*/
			if($loginhandler->IsLoggedIn())
			{
					$dataarray = new UserArray();
					$dataarray = $this->m_db->SelectUsers();
									
					
					foreach($dataarray->get() as $users){
						
						if($users->getUsername() != $_SESSION[LoginHandler::USERSESSION]){
							
							if($removeview->GetRemoveClick($users)){
								if($removemodel->RemoveUser($users->getId())){
									return $removemodel->RemoveList();
									
								}
								else {
									echo $removeview->Messages(RemoveView::CANNOT_REMOVE_USER);
								}
							}
						}	
					}
					return $removemodel->RemoveList();
				}
				
				return false;
			}
		}

?>